package com.kfd.demo.service.Impl;

import com.kfd.demo.dao.UserExpandDao;
import com.kfd.demo.entity.user.Address_Tb;
import com.kfd.demo.service.UserExpandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserExpandServiceImpl implements UserExpandService {

    @Autowired
    UserExpandDao userExpandDao;

    // 获取用户填的所有地址
    @Override
    public List getAddress(int u_id) {
        List list = userExpandDao.getAddress(u_id);
//        System.out.println(list);
        return list;
    }

    // 获取商品详细信息
    @Override
    public List getProductDetails(int right_menu_data_id) {
        List list = userExpandDao.getProductDetails(right_menu_data_id);
//        System.out.println(list);
        return list;
    }

    // 根据商品名字查询商品
    @Override
    public List queryCommodity(String commodityName) {
        return userExpandDao.queryCommodity(commodityName);
    }

    // 添加地址(将地址信息分配给用户)
    @Override
    public int allocationAddressToUser(int userId) {
        System.out.println("allocationAddressToUser(获取到用户的ID): " + userId);
        int count = 0;
        count = userExpandDao.allocationAddressToUser(userId);
        return count;
    }

    // 添加地址(地址的具体信息)
    @Override
    public int addAddress(Address_Tb address) {
        int count = 0;
        count = userExpandDao.addAddress(address);
        return count;
    }
}
